<template>
	<view class="content padding-about-34 padding-top-30">
		<view class="font-size-32 font-weight-bold">
			我的昵称
		</view>
		<view class="input display-flex space-between alig margin-top-20">
			<input type="nickname" v-model="nickname" maxlength="8" placeholder="请输入您的昵称" class="font-size-24" />
			<view class="font-size-24">
				{{nickname.length}}/8
			</view>
		</view>
		<view class="font-size-24 margin-top-20" style="color: #E72A2A;">
			*昵称可使用中文、英文、数字和部分字符
		</view>
		<view class="display-flex center margin-top-120">
			<view class="button" @click="submitEdit" style="padding: 24rpx 308rpx;">
				完成
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getUserInfo,
		profileUserInfo
	} from '@/utils/api/userApi.js'
	export default {
		components: {},
		data() {
			return {
				nickname: ''
			};
		},
		onReachBottom() {},
		onLoad(option) {
			this.nickname = option.name
		},
		onShow() {},
		methods: {
			submitEdit() {
				console.log(this.nickname);
				this.editInfo({
					nickname: this.nickname
				})
			},
			editInfo(obj) {
				uni.showLoading()
				profileUserInfo({
					...obj
				}).then(res => {
					uni.hideLoading()
					uni.showToast({
						title: '修改成功',
						icon: 'none'
					})
					uni.navigateBack()
				})
			},
		},
		computed: {},
		watch: {}
	};
</script>

<style scoped lang="scss">
	.input {
		padding: 20rpx;
		background: #FFFFFF;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		border: 2rpx solid #F8F8F8;
	}
</style>